Skip to main content
ICT
Lesson A12 - Iterations
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

LAB ASSIGNMENT A12.1 page 12 of 18

FunLoops

Background:

  1. Magic Square problem:

    1. Some perfect squares have unique mathematical properties. For example, 36 is:

      • a perfect square, 62
      • the sum of the integers 1 to 8 (1+2+3+4+5+6+7+8 = 36)
      • a “magic square” (any number that is both a perfect square AND equal to the sum of consecutive integers beginning with 1)

    2. The next magic square is 1225:

      • 352 = 1225
      • 1225 = sum of 1 to 49

    3. Write a method that prints the first n magic squares.

  2. Least Common Multiple (LCM) problem:

    1. Write a method that determines the Least Common Multiple of two integers. For example, the LCM of the following pairs:
      2, 3
      LCM = 6
      4, 10
      LCM = 20
      12, 15
      LCM = 60
      7, 70
      LCM = 70

Instructions:

  1. Find the first four magic squares. The first one is the integer 1.

  2. Find the LCM of the following pairs of values:

    15, 18
    40, 12
    2, 7
    100, 5

  3. Try finding the first 10 magic squares. This program will take so long that you can accurately time it. Experiment with this program by running it on computers with different clock speeds (number of megahertz).

 

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.